<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Performs preflight checks before the application runs
 * 
 * This function should contain checks to ensure required PHP extensions are
 * installed, PHP.ini file settings are set correctly, the PHP version is
 * new enough, etcetera
 *
 * @return boolean
 */
function preflight_check()
{	
	//
	// Do everything below only once per session
	//
	session_start();
	if (isset($_SESSION['preflight_check_pass']) && $_SESSION['preflight_check_pass'] == 'pass')
		return TRUE;

	//Ensure proper version of PHP
	if (phpversion() < '5.1')
	  show_error("This application requires at least PHP 5.1 to run properly!");

	//Ensure that there is an encryption key set in the config.php file
	$CFG =& load_class('Config');
	if ($CFG->item('encryption_key') == '' OR $CFG->item('encryption_key') == 'SET_ME')
		show_error("No encryption key has been set.  Halting execution.");

	//Woo hoo.. the check passed!
	$_SESSION['preflight_check_pass'] = 'pass';
	return TRUE;
}

/* EOF */